/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    void jinwei(ListNode* node) {
        if (node->val >= 10) {
            node->val -= 10;
            // add node
            if (node->next) {
                node->next->val += 1;
                jinwei(node->next);
            } else {
                node->next = new ListNode(1);
            }
        }
    }
    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
        if (l1 == nullptr) {
            return l2;
        }
        if (l2 == nullptr) {
            return l1;
        }
        ListNode* list = new ListNode(l1->val + l2->val);
        list -> next = addTwoNumbers(l1->next, l2->next);
        jinwei(list);
        return list;
    }
};